/*
 * @Descripttion: null
 * @Author: lcx
 * @version: v01
 * @Date: 2023-10-18 22:29:17
 * @LastEditors: lcx
 * @LastEditTime: 2023-10-18 23:03:20
 */
interface Command {
    void execute();
}

class Invoker {
    Command command;

    void setCommend(Command command) {
        this.command = command;
    }

    void executeCommend() {
        command.execute();
    }
}

class Tv {
    void on() {
        System.out.println("TV ON");
    }
    void off() {
        System.out.println("TV Off");
    }

}

class OnCommand implements Command {
    Tv tv;

    OnCommand(Tv tv) {
        this.tv = tv;
    }

    public void execute() {
        tv.on();
    }
}

class OffCommand implements Command {
    Tv tv;

    OffCommand(Tv tv) {
        this.tv = tv;
    }

    public void execute() {
        tv.off();
    }
}


class test {
    public static void main(String[] args) {
        Tv tv = new Tv();
        Invoker invoker = new Invoker();
        Command onCommand = new OnCommand(tv);
        Command offCommand = new OffCommand(tv);

        invoker.setCommend(offCommand);
        invoker.executeCommend();

        invoker.setCommend(onCommand);
        invoker.executeCommend();



    }
}